package com.groupfour.attendancemanagementsystem.controller;

import com.groupfour.attendancemanagementsystem.entity.DO.LeaveDO;
import com.groupfour.attendancemanagementsystem.service.impl.LeaveServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Controller
public class LeaveController {

    private LeaveServiceImpl leaveServiceImpl;

    @Autowired
    public LeaveController(LeaveServiceImpl leaveServiceImpl){
        this.leaveServiceImpl = leaveServiceImpl;
    }

    //在学生请假管理中初始页面的所有请假记录
    @RequestMapping("/allLeave")
    public String allLeave(Model model){
        List<LeaveDO> leaveDOList = leaveServiceImpl.findAllLeave();
        model.addAttribute("leaveDOList",leaveDOList);
        return "";
    }

    //通过提交时间、审批状态、原因、主题查询请假记录
    @RequestMapping("/findLeaveByStudent")
    public String findLeaveByStudent(LeaveDO leave,Model model){
        List<LeaveDO> leaveDOList = leaveServiceImpl.findLeaveByStudent(leave);
        model.addAttribute("leaveDOList",leaveDOList);
        return "";
    }


}
